import Vue from "vue";
import Router from 'vue-router'
// import Home from '../components/Home.vue'

Vue.use(Router)

const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}

export default new Router({
    routes: [
        {
            path: '/',
            // component: Home
            // component: () => import('@/components/Home') //路由懒加载
            component: resolve => require(['@/components/common/Search'], resolve)//异步组件
        },
        {
            path: '/home',
            component: () => import('@/components/Home')
        },
        {
            path: '/message',
            component: () => import('@/components/Message')
        },
        {
            path: '/statistics',
            component: () => import('@/components/common/Statistics')
        },
        {
            path: '/atlas',
            component: () => import('@/components/common/Atlas')
        },
        {
            path: '/browse',
            component: () => import('@/components/Browse')
        },
        {
            path: '/download',
            component: () => import('@/components/Download')
        },
        {
            path: '/search',
            component: () => import('@/components/common/Search')
        }
    ],
    mode: 'history'
})